﻿using System;

class Clinet
{
    static void Main(string[] agrs)
    {

        Console.WriteLine("hello world !");

        Wrap.voidFun();

        float[] _outs = new float[] { 1, 2, 3 };
        Wrap.addNum_safe(4f, 23f, ref _outs[0]);
        Console.WriteLine($"C# addNum out: {_outs[0]}");

        int rSNum = 0;
        var rSNd = Wrap.subNum_safe(64.5f, 12.5f, ref rSNum);
        Console.WriteLine($"C# subNum out: {rSNum} , ret : {rSNd.ptr} ");
        //float aa = *rSNd.ptr;
        Wrap.printaddress(rSNd, Wrap.AddRessType.INT);

        float[] mulNums = new float[3] { 6, 2, 2 };
        var rMul = Wrap.mulNum_safe(2.5f, mulNums, mulNums.Length);
        Console.WriteLine($"C# mulNum out: {rMul}");

        //
        string srcStr = "<test string in and ret!>";
        byte[] buf = new byte[256];
        buf[0] = 72;
        buf[2] = 87;
        //char[] buf = new char[256];
        var _str = Wrap.repeatStr_safe(srcStr, buf);
        //var _str = Wrap.repeatStr_safe(srcStr, new byte[256]);
        //var _str = Wrap.repeatStr(srcStr,a);
        //string b_str = System.Text.Encoding.Default.GetString(buf);
        //Console.WriteLine($"C# repeatStr src: {srcStr} out: {b_str}");
        Console.WriteLine($"C# repeatStr src: {srcStr} out: {_str}");

        //
        var tpd = Wrap.testPDefVal();
        Console.WriteLine($"C# testPDefVal out: {tpd}");


        //约定测试
        string resultStr = "";
        Wrap.regStrAct_safe((str) =>
        {
            resultStr = str;
        });

        //
        Wrap.pString_safe("this is test Text", new byte[256]);
        Console.WriteLine(resultStr);

        //
        var retStr = Wrap.retString_safe(new byte[256]);
        Console.WriteLine(retStr);

        //
        int[] int_arr = new int[10];
        int_arr[0] = 8546;
        var vH = Wrap.retHVoid_safe(int_arr);
        Console.WriteLine(vH.ptr);

        //
        Wrap.pHVoid_safe(vH, new byte[256]);
        Console.WriteLine(resultStr);

        //
        var h_mesh = Wrap.retHStruct();

        //
        Wrap.pHStruct_safe(h_mesh, new byte[256]);
        Console.WriteLine(resultStr);

        //
        int val_out = 0;
        Wrap.pSuffixOut_safe(ref val_out);
        Console.WriteLine(val_out);

        //
        int[] suf_arr = { 4, 12, 96 };
        Wrap.pSuffixArr_safe(suf_arr, suf_arr.Length, new byte[256]);
        Console.WriteLine(resultStr);

        //
        Wrap.pSuffixHandle_safe(vH , new byte[256]);
        Console.WriteLine(resultStr);

        //
        float[] f_arr = new float[3];
        int arrLen = 0;
        var ret_arr = Wrap.retAliasArray_safe(f_arr , f_arr.Length , ref arrLen);
        Console.WriteLine(ret_arr[0]);
    }

}


